package com.woniuxy.mesboot.service.impl;

import com.woniuxy.mesboot.dto.MatStorageDTO;
import com.woniuxy.mesboot.entity.MatStorage;
import com.woniuxy.mesboot.mapper.MatStorageMapper;
import com.woniuxy.mesboot.service.MatStorageService;
import com.woniuxy.mesboot.vo.MatVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class MatStorageServiceImpl implements MatStorageService {
    @Resource
    private MatStorageMapper matStorageMapper;

    @Override
    public int addMat(MatStorageDTO record) {
        Long matId = record.getMatId();
        MatStorage matStorage = matStorageMapper.selectByPrimaryKey(matId);
        matStorage.setMatNum(matStorage.getMatNum()+record.getMatNum());
        int i = matStorageMapper.updateByPrimaryKeySelective(matStorage);
        return i;
    }

    @Override
    public List<MatVO> selectAll() {
        return matStorageMapper.selectAll();
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return matStorageMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(MatStorage record) {
        return matStorageMapper.insert(record);
    }

    @Override
    public int insertSelective(MatStorage record) {
        return matStorageMapper.insertSelective(record);
    }

    @Override
    public MatStorage selectByPrimaryKey(Long id) {
        return matStorageMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(MatStorage record) {

        return matStorageMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(MatStorage record) {
        return matStorageMapper.updateByPrimaryKey(record);
    }

    @Override
    public int updateStorage(MatStorageDTO record) {
        return matStorageMapper.updateStorage(record);
    }
}
